# ------------------------------------------------------------------------------------
# ATM机的存取款功能
# ATM角色  50000
# 用户角色  5000
# 1, 登陆功能
# 2, 菜单界面
#    1, 取款
#    2, 存款
#    3, 查询
class ATM:
    # 初始金额
    Atm_money = 50000
    User_money = 5000
    username = "root"
    passwd = "123456"

    # 登陆
    def login(self, user, pwd):
        if self.username == user and self.passwd == pwd:
            print("登陆成功!")
            input("请按回车....")
            return True
        else:
            print("登陆失败!")
            input("请按回车....")
            return False

    # 菜单
    def menu1(self):
        print("**********")
        print("1, 用户登陆")
        print("2, 退出")
        print("**********")

    def menu2(self):
        print("**********")
        print("1, 存款")
        print("2, 取款")
        print("3, 查询账户")
        print("4, 退出")
        print("**********")

    # 存款
    def dep(self, dep):
        self.Atm_money += dep
        self.User_money += dep

    # 取款
    def wit(self, wit):
        if wit > self.User_money:
            print("用户账号没有更多金额")
        elif wit > self.Atm_money:
            print("ATM机没有更多金额")
        else:
            self.Atm_money -= wit
            self.User_money -= wit


wang = ATM()
while True:
    wang.menu1()
    choice1 = input()
    if choice1 == '1':
        username = input("请输入用户名: ")
        passwd = input("请输入用户密码: ")
        if wang.login(username, passwd):
            while True:
                wang.menu2()
                choice2 = input()
                if choice2 == '1':
                    deposit = int(input("请输入存款金额: "))
                    wang.dep(deposit)
                if choice2 == '2':
                    withdrawal = int(input("请输入取款金额: "))
                    wang.wit(withdrawal)
                if choice2 == '3':
                    print("用户账户金额: ", wang.User_money)
                if choice2 == '4':
                    break
                input("请按回车....")
    if choice1 == '2':
        break
